#pragma once
#include "Result.h"
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;

class Course
{
	
private:
	string name;
	int id;

	vector<Result> r;

public:

	Course()
	{
		name = "";
		id = -1;
	}

	Course(string name, int id)
	{
		this->name = name;
		this->id = id;
	}

	vector<Result>& Getresults()
	{
		return r;
	}

	friend ostream& operator<<(ostream &o, const Course &Course)
	{
		o << "(";
		o << Course.name << ",";
		o << Course.id;
		o << ")";
		return o;
	}

	friend istream& operator>>(istream &i, Course &Course)
	{
		string s;
		getline(i, s, '(');
		getline(i, Course.name, ',');
		
		getline(i, s, ')');
		istringstream iss(s);
		iss >> Course.id;

		return i;
	}

	friend bool operator==(const Course c1, const Course c2)
	{
		return c1.GetId() == c2.GetId();
	}

	void AddResult(Result result)
	{
		r.push_back(result);
	}


	string PrintCourseResult(int l)
	{
		ostringstream oss;
		oss << "(" << r[l].GetTestID() << "," << r[l].GetPoints() << ")" << endl;
		return oss.str();
	}


	string GetName() { return this->name; }

	int GetId() const { return this->id; }
	void SetId(int id) { this->id = id; }

	~Course()
	{
	}
};

